//
//  ImageControl.m
//  taishan
//
//  Created by mac on 2019/4/16.
//  Copyright © 2019年 jznrj. All rights reserved.
//

#import "ImageControl.h"
#import <Masonry.h>

@interface ImageControl ()

@property(nonatomic, strong) UIImageView *backgroundImageView;

@end

@implementation ImageControl

-(id) init{
    
    self = [super init];
    if (!self) {
        return nil;
    }
    
    _backgroundImageView = [[UIImageView alloc]init];
    [self addSubview:_backgroundImageView];
    [_backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.equalTo(self);
        make.height.width.equalTo(self);
    }];
    return self;
}

-(id) initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (!self) {
        return nil;
    }
    
    _backgroundImageView = [[UIImageView alloc]init];
    [self addSubview:_backgroundImageView];
    [_backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.equalTo(self);
        make.height.width.equalTo(self);
    }];
    return self;
}
-(void) setImageName:(NSString *)imageName{
    
    _imageName = [imageName copy];
    _backgroundImageView.image = [UIImage imageNamed:_imageName];
}
@end

